package com.mo.design.pattern.struct.bridge;

public class BridgeTest {

    public static void main(String[] args) {
        new MyMessageClient(new WindowsImplementation()).sendMessageToAll("abc@gmail.com", "Test");
    }
}

interface PlatformBridge {
    public void forwardMessage(String msg);
}

class WindowsImplementation implements PlatformBridge {

    @Override
    public void forwardMessage(String msg) {
        System.out.printf("send message \n%s \n From the windows machine", msg);
    }
}

class PosixImplementation implements PlatformBridge {

    @Override
    public void forwardMessage(String msg) {
        System.out.printf("send message \n %s \n From the linux machine", msg);
    }
}

class MessageSender {
    private PlatformBridge implementation;

    public MessageSender (PlatformBridge implementation) {
        this.implementation = implementation;
    }

    public void sendMessage(String from, String to, String body) {
        implementation.forwardMessage(String.format("From : %s \nTo : %s \nBody : %s", from, to, body));
    }
}

class MyMessageClient extends MessageSender {
    private String to = "development_all@abc.com";

    public MyMessageClient (PlatformBridge im) {
        super(im);
    }

    public void sendMessageToAll(String from , String body) {
        sendMessage(from ,to, body);
    }
}